// view/my/diancan/jibensz/jibensz.js
let app = getApp()
let yuming = app.globalData.yuming
const request = require('../../config/request');
Page({
  /**
   * 页面的初始数据
   */
  ...request,
  data: {
    yuming: yuming,
    heights: '',
    title: "基本设置",
    isyyzt: '', //营业状态
    issmdc: '', //扫码点餐
    id: '', //后台反的id
    yyzt: '', //营业状态 true 和 false 0开启
    smdc: '', //扫码点餐true和false0开启
    // 基本设置 0 开启
  },
  // 营业状态
  bindyyzt(e) {
    var value = e.detail.value
    this.setData({
      isyyzt: value
    })
  },
  // 扫码点餐
  bindsmdc(e) {
    var value = e.detail.value
    this.setData({
      issmdc: value
    })
  },
  // 确定
  queding() {
    var that = this
    this.myRequest(yuming + 'hallfood/goodsSaveShopSetting', {
      shopId: wx.getStorageSync('shopId'),
      id: that.data.id,
      isBusiness: that.data.isyyzt,
      isScan: that.data.issmdc
    }, 'POST').then(res => {
      wx.showToast({
        title: res.data.msg,
        icon: 'none'
      })
      that.xq()
      // setTimeout(function(){

      // },1000)
    })
  },
  // 详情接口
  xq() {
    var that = this
    wx.showLoading({
      title: '加载中',
      icon: 'none'
    })
    this.myRequest(yuming + 'hallfood/goodsFindShopSetting', {
      shopId: wx.getStorageSync('shopId')
    }, 'POST').then(res => {
      wx.hideLoading();
      that.setData({
        isyyzt: res.data.data.isBusiness,
        issmdc: res.data.data.isScan,
        id: res.data.data.id,
      })
      if (that.data.isyyzt == 1) {
        that.setData({
          yyzt: false
        })
      } else {
        that.setData({
          yyzt: true
        })
      }
      if (that.data.issmdc == 1) {
        that.setData({
          smdc: false
        })
      } else {
        that.setData({
          smdc: true
        })
      }
    })
  },
  backs() {
    wx.navigateBack({
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5
    })
    this.xq()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})